<?php include template("header");?>
<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="content">
    <form action="/team/buy.php?id=<?php echo $team['id']; ?>" method="post" class="validator">
	<input id="deal-per-number" value="<?php echo $team['per_number']; ?>" type="hidden" />
    <div id="deal-buy" class="box">
        <div class="box-top"></div>
        <div class="box-content">
            <div class="head"><h2>Đơn đặt hàng <?php if($team['farefree']>0){?>&nbsp;(Miễn phí khi đặt hàng với số lượng >= <span class="currency"><?php echo $team['farefree']; ?></span>)<?php }?></h2></div>
            <div class="sect">
            <table class="order-table">
                <tr>
                    <th class="deal-buy-desc">Sản phẩm</th>
                    <th class="deal-buy-quantity">số lượng</th>
                    <th class="deal-buy-multi"></th>
                    <th class="deal-buy-price">Đơn giá/ <span class="money"><?php echo $currency; ?></span></th>
                    <th class="deal-buy-equal"></th>
                    <th class="deal-buy-total">Thành tiền/ <span class="money"><?php echo $currency; ?></span></th>
                </tr>
                <tr>
                    <td class="deal-buy-desc"><?php echo $team['title']; ?></td>
                    <td class="deal-buy-quantity"><input type="text" class="input-text f-input" maxlength="4" name="quantity" value="<?php echo $order['quantity']; ?>" ff="<?php echo abs(intval($team['farefree'])); ?>" id="deal-buy-quantity-input" <?php echo $team['per_number']==1?'readonly':''; ?> /><br /><span style="font-size:12px;color:gray;"><?php if($team['per_number']==0){?>at most 9999 pieces<?php } else { ?>số lượng tối đa <?php echo $team['per_number']; ?><?php }?></span></td>
                    <td class="deal-buy-multi">x</td>
                    <td class="deal-buy-price"><span id="deal-buy-price"><?php echo $team['team_price']; ?></span></td>
                    <td class="deal-buy-equal">=</td>
                    <td class="deal-buy-total"><span id="deal-buy-total"><?php echo $order['quantity']*$team['team_price']; ?></span></td>
                </tr>
				<?php if($team['delivery']=='express'){?>
                <tr>
                    <td class="deal-buy-desc">Phí vận chuyển</td>
                    <td class="deal-buy-quantity"></td>
                    <td class="deal-buy-multi"></td>
                    <td class="deal-buy-price"><span id="deal-express-price" v="<?php echo $team['fare']; ?>"><?php echo $team['fare']; ?></span></td>
                    <td class="deal-buy-equal">=</td>
                    <td class="deal-buy-total"><span id="deal-express-total" v="<?php echo $team['fare']; ?>"><?php echo $team['fare']; ?></span></td>
                </tr>
				<?php }?>

				<tr class="order-total">
                    <td class="deal-buy-desc"><strong>Tổng tiền</strong></td>
                    <td class="deal-buy-quantity"></td>
                    <td class="deal-buy-multi"></td>
                    <td class="deal-buy-price"></td>
                    <td class="deal-buy-equal">=</td>
                    <td class="deal-buy-total"><strong id="deal-buy-total-t"><?php echo $order['origin']; ?></strong></td>
                </tr>
            </table>
			<!-- show hinh voucher -->
			<?php if((!empty($team['image5']) || !empty($team['image6']))){?>
			<div id="voucher_note">Bạn sẽ nhận được voucher do <?php echo $INI['system']['abbreviation']; ?> cung cấp sau khi thanh toán.<br>
				<?php if((!empty($team['image5']) && empty($team['image6']))){?>
				<div style="width: 50%;"><img width='100%' src="../static/<?php echo $team['image5']; ?>"></div>
				<?php }?>
				<?php if((empty($team['image5']) && !empty($team['image6']))){?>
				<div style="width: 50%;"><img width='100%' src="../static/<?php echo $team['image6']; ?>"></div>
				<?php }?>
				<?php if((!empty($team['image5']) && !empty($team['image6']))){?>
				<div style="float: left ;width: 49%; padding: 3px;"><img width='100%' height='200px' src="../static/<?php echo $team['image5']; ?>"></div>
				<div style="float: left; width: 49%; padding: 3px;"><img width='100%' height='200px' src="../static/<?php echo $team['image6']; ?>"></div>
				<?php }?>
			</div>
			<?php }?>
			<!-- end show hinh -->
			<?php if($team['delivery']=='express'){?>
			<div class="expresstip"><?php echo nl2br(($team['express'])); ?></div>
			<div class="wholetip clear"><h3>Thông tin nhận phiếu</h3></div>
			<div class="field username">
				<label>Người nhận</label>
				<input type="text" size="30" name="realname" id="settings-realname" class="f-input" value="<?php echo $login_user['realname']; ?>" require="true" datatype="require" />
			</div>
			<div class="field mobile">
				<label>Số điện thoại</label>
				<input type="text" size="30" name="mobile" id="settings-mobile" class="number" value="<?php echo $login_user['mobile']; ?>" require="true" datatype="mobile" maxLength="11" /> 
				<span class="inputtip">Vui lòng cung cấp chính xác số điện thoại, dùng để liên lạc khi giao phiếu</span>
			</div>
				<div class="field username">
				<label>Địa chỉ</label>
				<input type="text" size="30" name="address" id="settings-address" class="f-input" value="<?php echo $login_user['address']; ?>" require="true" datatype="require" />
			</div>
			<?php } else { ?>
			<div class="field mobile">
				<label>mobile number</label>
				<input type="text" size="30" name="mobile" id="settings-mobile" class="number" value="<?php echo $login_user['mobile']; ?>"  datatype="mobile" maxLength="11" /><span class="inputtip">Please input a correct mobile number(you may buy for your friend)</span>
			</div>
			<?php }?>
			<div class="wholetip clear"><h3>Thông tin thêm</h3></div>
			<?php if($condbuy=nanooption($team['condbuy'])){?>
			<div class="field mobile">
				<label>order options</label>
				<select name="condbuy" class="f-input" style="width:auto;"><?php echo Utility::Option(array_combine($condbuy, $condbuy), 'condbuy'); ?></select>
			</div>
			<?php }?>
			<div class="field mobile">
				<label>Ghi chú</label>
				<textarea name="remark" style="width:400px;height:80px;padding:2px;"><?php echo htmlspecialchars($order['remark']); ?></textarea>
			</div>
            <input type="hidden" name="id" value="<?php echo $order['id']; ?>" />
			<div class="form-submit"><input type="submit" class="formbutton" name="buy" value="Xác nhận, Mua"/></div>
            </div>
        </div>
        <div class="box-bottom"></div>
    </div>
    </form>
</div>
<div id="sidebar">
	<!--{//include block_side_credit}-->
</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->

<script>
window.x_init_hook_dealbuy = function(){
	X.team.dealbuy_farefree(<?php echo abs(intval($order['quantity'])); ?>);
	X.team.dealbuy_totalprice();
};
</script>
<?php include template("footer");?>
